package com.yunhe.marketing.util;

import com.yunhe.common.exception.ArgumentErrorException;
import com.yunhe.common.util.StringUtil;
import com.yunhe.marketing.constant.EnterpriseConsts;
import com.yunhe.marketing.domain.Enterprise;

/**
 * @Author: DongWenYu
 * @Date: 2021/2/26 14:39
 */
public class EnterpriseUtil {

    public static String judgeInformationType(Enterprise enterprise){
        if (StringUtil.isEmpty(enterprise.getIntention()) && StringUtil.isEmpty(enterprise.getIntentionArea())
                && StringUtil.isEmpty(enterprise.getPurpose()) && StringUtil.isEmpty(enterprise.getAreaRequirement())
                && StringUtil.isEmpty(enterprise.getFloorHeight()) && StringUtil.isEmpty(enterprise.getBearing())
                && StringUtil.isEmpty(enterprise.getElectricityConsumption()) && StringUtil.isEmpty(enterprise.getMatchingRequirement())
                && StringUtil.isEmpty(enterprise.getIntentionPark()) && StringUtil.isEmpty(enterprise.getOther())){
            return EnterpriseConsts.INFORMATION_TYPE.Clue.value();
        }else {
            return EnterpriseConsts.INFORMATION_TYPE.Demand.value();
        }
    }

    public static Boolean canAllocated(Enterprise enterprise) throws ArgumentErrorException {
        if (EnterpriseConsts.ALLOCATION_STATE.Allocated.value().equals(enterprise.getAllocationStatus())){
            throw new ArgumentErrorException("已分配，请勿重复分配!");
        }else if (EnterpriseConsts.ALLOCATION_STATE.KnockedBack.value().equals(enterprise.getAllocationStatus()) &&
                EnterpriseConsts.FEEDBACK_STATE.HasIntention.value().equals(enterprise.getFeedbackStatus())){
            throw new ArgumentErrorException("已回敲且有意向，请勿重复分配!");
        }
        return true;
    }
}
